<template>
  <div class="address-page">
    <!--<headBar  isBack="show" >-->
      <!--<div slot="xm-header-center">-->
        <!--<div class="xm-header-title">地址管理</div>-->
      <!--</div>-->
    <!--</headBar>-->
    <ul class="address-list">
      <li class="flex" v-for="item in addressList">
        <i class="icon icon-dingwei dingwei"></i>
        <div class="flex-1 address-item">
          <h3>{{item.contactor}} <span>{{item.phone}}</span></h3>
          <p class="address">地址：{{item.provinceName}} {{item.cityName}} {{item.address}}</p>
          <p class="edit">
            <span class="span1" @click="deleteAddress(item.id)"><i class="icon icon-shanchu-copy"></i>删除</span>
            <span @click="edit(item.id)"><i class="icon icon-bianji" style="font-size: .35rem"></i>编辑</span>
          </p>
        </div>
      </li>
    </ul>
    <!--数据为空-->
    <div class="empty marginTop20" v-show="addressList.length==0">
      <i class="icon icon-wujieguoyangshi"></i>
      <p class="marginTop20">没有数据</p>
    </div>

    <section class="bottom-section">
      <div class="foot-bar flex">
        <a href="javascript:void(0)" class="flex-1" @click="add">
          <i class="icon icon-add"></i>
          新增收货地址
        </a>
      </div>
    </section>
  </div>
</template>
<script>
  export default {
    props: {},
    data() {
      return {
        addressList: []
      };
    },
    methods: {
        //获取收货地址列表
      getAddress(){
        getAddressList().then(data=>{
            if(data.returnCode == '000000'){
              this.addressList = data.result.buyerAddressList;
            }
        })
      },
      /**
       * 删除收货地址
       * @param <string> 收货地址ID
       * */
      deleteAddress(id){
        delAddress({id: id}).then(data=>{
            if(data.returnCode == '000000'){
              this.getAddress();
            }
        });
      },
      /**
       * 编辑收货地址
       * @param <string> 收货地址ID
       * */
      edit(id){
        this.$router.push({name: 'addressEdit',params:{addressId: id}});
      },
      /**
      * 新增收货地址
      * */
      add(){
          this.$router.push({name: 'addressEdit',params:{addressId: 'add'}});
      }
    },
    filters: {},
    created() {
      this.getAddress();
    },
    mounted(){

    },
    components: {
    }
  };
</script>
<style lang="less">
  @import "./address.less";
</style>
